const express = require('express');

const app = express();
const path = require("path");
const fs = require("fs");

app.get('/', (req,res) => {
    var fileContent = fs.readFileSync(path.join(__dirname, '/demo2.html'));
    
    //向前端响应
    res.writeHead(200, {"Content-Type": "text/html"});
    res.write(fileContent);
    res.end();
})

app.get('/getimg', (req,res) => {
    var fileContent = fs.readFileSync(path.join(__dirname, '/icon.png'));
    res.writeHead(200, {"Content-Type": "image/png"});
    res.write(fileContent);
    res.end();
})

app.listen(8081);